home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbsnip.zip / OFONT.BAS < prev    next >
BASIC Source File  |  1997-06-20  |  5KB  |  117 lines

  1. ' Phillip Jay Cohen's Outlined Font Routines:
  2. ' Demo Program
  3.  
  4. ' Everything appearing here in the main program is just demonstration
  5. ' and won't be of any use to any of you (or at least I don't think so)
  6. ' Besides, it's not hard to understand what's going on here, it's the
  7. ' actual routines that do most of the work. These are just calls, and
  8. ' a pretty border to keep us happy.  If you want to use these routines
  9. ' you will somewhat need to understand how to call them.  Just run the
  10. ' program to find out about the syntax and stuff, or if you are lazy,
  11. ' you can check directly in the code, but then you won't know how it
  12. ' looks.  The routines will only work in screen mode 13, as I am use-
  13. ' ing VGA video memory.  I will be very happy if you distribute these
  14. ' routines, and if you think they're useful or maybe you feel warm and
  15. ' squooshy inside, then please  E-mail me and tell me.  My email is:
  16. ' cohennet@erols.com.  Thanks for taking time to read this. -- P.J.C.
  17.  
  18. DEFINT A-Z
  19. DECLARE SUB OFont (Text$, X, Y, Fore, Back, FontFlag)   'Main font routine
  20. SCREEN 13    '320x200 VGA and MCGA screen mode
  21.  
  22. '*** Demo ***
  23. LINE (1, 0)-(318, 0), 4
  24. LINE (0, 1)-(0, 198), 4
  25. LINE (1, 199)-(318, 199), 4
  26. LINE (319, 1)-(319, 198), 4
  27. LINE (1, 1)-(318, 198), 41, B
  28. LINE (2, 2)-(317, 197), 42, B
  29. LINE (3, 3)-(316, 196), 14, B
  30. PAINT (4, 4), 25, 14
  31.  
  32. OFont "PHILLIP JAY COHEN'S", 0, 10, 2, 144, 1
  33. OFont "OUTLINED FONT", 60, 25, 43, 114, 0
  34. OFont "DEMO PROGRAM", 180, 25, 32, 1, 0
  35. OFont "Syntax:", 0, 50, 15, 8, 1
  36. OFont "OFont Text$, X, Y, Fore, Back", 0, 65, 40, 4, 1
  37. OFont "Where:", 10, 85, 9, 33, 0
  38. OFont "Text$ = The text to be printed", 70, 85, 11, 3, 0
  39. OFont "X = The horizontal coordinate for the", 0, 100, 35, 5, 1
  40. OFont "upper-left hand corner of the text", 0, 110, 35, 5, 1
  41. OFont "Y = The vertical coordinate for the", 10, 125, 42, 41, 0
  42. OFont "upper-left hand corner of the text", 0, 135, 42, 41, 1
  43. OFont "Fore = The text's foreground color", 0, 150, 13, 37, 1
  44. OFont "Back = The text's background color", 0, 165, 44, 6, 1
  45. OFont "PRESS A KEY", 0, 185, 15, 8, 1
  46. GOSUB PressAndClear
  47.  
  48. OFont "Also Including", 0, 50, 15, 8, 1
  49. OFont "A Fonting routine,", 25, 65, 40, 4, 0
  50. OFont "which has the", 190, 65, 11, 3, 0
  51. OFont "same syntax, except for the X argument", 0, 75, 11, 3, 1
  52. OFont "These routines only work in screen", 0, 90, 35, 5, 1
  53. OFont "mode 13, but have many advantages,", 0, 100, 35, 5, 1
  54. OFont "Including:", 0, 115, 44, 6, 1
  55. OFont "Outlining (obviously), placement at", 0, 130, 42, 41, 1
  56. OFont "exact coordinates (unlike PRINT),", 0, 140, 42, 41, 1
  57. OFont "avoid erasing the background, and", 0, 150, 42, 41, 1
  58. OFont "are relatively FAST for QBasic", 0, 160, 42, 41, 1
  59. OFont "MORE -->", 0, 173, 13, 37, 1
  60. GOSUB PressAndClear
  61.  
  62. OFont "Please,", 0, 50, 15, 8, 1
  63. OFont "Feel free to distribute these routines", 0, 65, 40, 4, 1
  64. OFont "Try to give me credit when you use", 0, 80, 11, 3, 1
  65. OFont "them, if you can (I don't think that's", 0, 90, 11, 3, 1
  66. OFont "asking too much, do you?)", 0, 100, 11, 3, 1
  67. OFont "Unless you have a lot of programing", 0, 115, 9, 33, 1
  68. OFont "experience, don't try to understand", 0, 125, 9, 33, 1
  69. OFont "the OFont routine; you don't need to", 0, 135, 9, 33, 1
  70. OFont "know how the routine works to use it", 0, 145, 9, 33, 1
  71. OFont "For more info, you can contact me at:", 0, 160, 35, 5, 1
  72. OFont "cohennet@erols.com", 0, 173, 44, 6, 1
  73. GOSUB PressAndClear
  74.  
  75. SCREEN 0: WIDTH 80: CLS : END
  76. '*** End Demo ***
  77.  
  78. '*** PressAndClear Subroutine for demo
  79. PressAndClear:
  80. Buffer = &H1A
  81. DEF SEG = &H40
  82. POKE Buffer, PEEK(Buffer + 2)    'Clear keyboard buffer
  83. DEF SEG
  84. DO: LOOP WHILE INKEY$ = ""       'Wait for key press
  85. LINE (4, 45)-(315, 180), 25, BF  'Clear our working area
  86. RETURN
  87. '*** End Subroutine
  88.  
  89. SUB OFont (Text$, X, Y, Fore, Back, FontFlag)
  90. IF FontFlag <> 0 THEN X = 160 - INT(LEN(Text$) * 4)
  91. DEF SEG = &HFFA6                              'Stores masks for letters
  92. FOR Letter = 1 TO LEN(Text$)                  'Does each letter
  93. Address = (8 * ASC(MID$(Text$, Letter))) + 14 'Address for start of letter
  94. FOR Height = 0 TO 7                       'Each letter is an 8x8 pixel matrix
  95. Mask = PEEK(Address + Height) * 128   'Address for mask of each line of letter
  96. LINE (X + Curntx + 1, Y + Height + 1)-(X + 9 + Curntx, Y + Height + 1), Fore, , Mask
  97. NEXT
  98. Curntx = Curntx + 8                   'Advances X axis by 8 for next letter
  99. NEXT                                  'Continue to next letter
  100. DEF SEG = &HA000                      'Change to video memory
  101. IF Back > 0 THEN                      'Background color can't be color 0
  102. FOR V = Y TO Y + 7                    'Again, they're 8x8 pixels
  103. FOR H = X TO (LEN(Text$) * 8) - 1 + X 'Calculates length of text in pixels
  104. PK0& = PEEK(H + V * 320&)             'Is point at H,V = to foreground color?
  105. PK1& = PEEK(H + 1 + (V + 1) * 320&)   'Is point at H+1, V+1 = to foreground?
  106. PK2& = PEEK(H + 1 + V * 320&)         'Is point at H+1, V = to foreground?
  107. PT& = H + V * 320&                    'Video memory pointer
  108. IF PK0& <> Fore THEN                  'If this is foreground, don't overlap it
  109. IF PK1& = Fore OR PK2& = Fore THEN POKE PT&, Back    'Put pixel into memory
  110. END IF
  111. NEXT H     'Next horizontal
  112. NEXT V     'Next vertical
  113. END IF
  114. DEF SEG    'Put us back where
  115. END SUB    'We started
  116.  
  117.